<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - smart_ptr/detail/shared_count.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">smart_ptr/detail</a> - shared_count.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">25</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">76.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">19</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
<span class="lineNum">       2 </span>                : #define BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
<span class="lineNum">       3 </span>                : 
<span class="lineNum">       4 </span>                : // MS compatible compilers support #pragma once
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : #if defined(_MSC_VER) &amp;&amp; (_MSC_VER &gt;= 1020)
<span class="lineNum">       7 </span>                : # pragma once
<span class="lineNum">       8 </span>                : #endif
<span class="lineNum">       9 </span>                : 
<span class="lineNum">      10 </span>                : //
<span class="lineNum">      11 </span>                : //  detail/shared_count.hpp
<span class="lineNum">      12 </span>                : //
<span class="lineNum">      13 </span>                : //  Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
<span class="lineNum">      14 </span>                : //  Copyright 2004-2005 Peter Dimov
<span class="lineNum">      15 </span>                : //
<span class="lineNum">      16 </span>                : // Distributed under the Boost Software License, Version 1.0. (See
<span class="lineNum">      17 </span>                : // accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">      18 </span>                : // http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">      19 </span>                : //
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : #ifdef __BORLANDC__
<span class="lineNum">      22 </span>                : # pragma warn -8027     // Functions containing try are not expanded inline
<span class="lineNum">      23 </span>                : #endif
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                : #include &lt;boost/config.hpp&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/checked_delete.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/throw_exception.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/smart_ptr/bad_weak_ptr.hpp&gt;
<span class="lineNum">      29 </span>                : #include &lt;boost/smart_ptr/detail/sp_counted_base.hpp&gt;
<span class="lineNum">      30 </span>                : #include &lt;boost/smart_ptr/detail/sp_counted_impl.hpp&gt;
<span class="lineNum">      31 </span>                : #include &lt;boost/detail/workaround.hpp&gt;
<span class="lineNum">      32 </span>                : // In order to avoid circular dependencies with Boost.TR1
<span class="lineNum">      33 </span>                : // we make sure that our include of &lt;memory&gt; doesn't try to
<span class="lineNum">      34 </span>                : // pull in the TR1 headers: that's why we use this header 
<span class="lineNum">      35 </span>                : // rather than including &lt;memory&gt; directly:
<span class="lineNum">      36 </span>                : #include &lt;boost/config/no_tr1/memory.hpp&gt;  // std::auto_ptr
<span class="lineNum">      37 </span>                : #include &lt;functional&gt;       // std::less
<span class="lineNum">      38 </span>                : #include &lt;new&gt;              // std::bad_alloc
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : namespace boost
<span class="lineNum">      41 </span>                : {
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : namespace detail
<span class="lineNum">      44 </span>                : {
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : int const shared_count_id = 0x2C35F101;
<span class="lineNum">      49 </span>                : int const   weak_count_id = 0x298C38A4;
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span>                : #endif
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                : struct sp_nothrow_tag {};
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                : class weak_count;
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                : class shared_count
<span class="lineNum">      58 </span>                : {
<span class="lineNum">      59 </span>                : private:
<span class="lineNum">      60 </span>                : 
<span class="lineNum">      61 </span>                :     sp_counted_base * pi_;
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      64 </span>                :     int id_;
<span class="lineNum">      65 </span>                : #endif
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                :     friend class weak_count;
<span class="lineNum">      68 </span>                : 
<span class="lineNum">      69 </span>                : public:
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span><span class="lineCov">             57 :     shared_count(): pi_(0) // nothrow</span>
<span class="lineNum">      72 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      73 </span>                :         , id_(shared_count_id)
<span class="lineNum">      74 </span>                : #endif
<span class="lineNum">      75 </span>                :     {
<span class="lineNum">      76 </span><span class="lineCov">             57 :     }</span>
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span><span class="lineCov">             85 :     template&lt;class Y&gt; explicit shared_count( Y * p ): pi_( 0 )</span>
<span class="lineNum">      79 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">      80 </span>                :         , id_(shared_count_id)
<span class="lineNum">      81 </span>                : #endif
<span class="lineNum">      82 </span>                :     {
<span class="lineNum">      83 </span>                : #ifndef BOOST_NO_EXCEPTIONS
<span class="lineNum">      84 </span>                : 
<span class="lineNum">      85 </span>                :         try
<span class="lineNum">      86 </span>                :         {
<span class="lineNum">      87 </span><span class="lineCov">             85 :             pi_ = new sp_counted_impl_p&lt;Y&gt;( p );</span>
<span class="lineNum">      88 </span>                :         }
<span class="lineNum">      89 </span><span class="lineNoCov">              0 :         catch(...)</span>
<span class="lineNum">      90 </span>                :         {
<span class="lineNum">      91 </span><span class="lineNoCov">              0 :             boost::checked_delete( p );</span>
<span class="lineNum">      92 </span><span class="lineNoCov">              0 :             throw;</span>
<span class="lineNum">      93 </span>                :         }
<span class="lineNum">      94 </span>                : 
<span class="lineNum">      95 </span>                : #else
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                :         pi_ = new sp_counted_impl_p&lt;Y&gt;( p );
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                :         if( pi_ == 0 )
<span class="lineNum">     100 </span>                :         {
<span class="lineNum">     101 </span>                :             boost::checked_delete( p );
<span class="lineNum">     102 </span>                :             boost::throw_exception( std::bad_alloc() );
<span class="lineNum">     103 </span>                :         }
<span class="lineNum">     104 </span>                : 
<span class="lineNum">     105 </span>                : #endif
<span class="lineNum">     106 </span><span class="lineCov">             85 :     }</span>
<span class="lineNum">     107 </span>                : 
<span class="lineNum">     108 </span>                : #if defined( BOOST_MSVC ) &amp;&amp; BOOST_WORKAROUND( BOOST_MSVC, &lt;= 1200 )
<span class="lineNum">     109 </span>                :     template&lt;class Y, class D&gt; shared_count( Y * p, D d ): pi_(0)
<span class="lineNum">     110 </span>                : #else
<span class="lineNum">     111 </span><span class="lineCov">              6 :     template&lt;class P, class D&gt; shared_count( P p, D d ): pi_(0)</span>
<span class="lineNum">     112 </span>                : #endif
<span class="lineNum">     113 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     114 </span>                :         , id_(shared_count_id)
<span class="lineNum">     115 </span>                : #endif
<span class="lineNum">     116 </span>                :     {
<span class="lineNum">     117 </span>                : #if defined( BOOST_MSVC ) &amp;&amp; BOOST_WORKAROUND( BOOST_MSVC, &lt;= 1200 )
<span class="lineNum">     118 </span>                :         typedef Y* P;
<span class="lineNum">     119 </span>                : #endif
<span class="lineNum">     120 </span>                : #ifndef BOOST_NO_EXCEPTIONS
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                :         try
<span class="lineNum">     123 </span>                :         {
<span class="lineNum">     124 </span><span class="lineCov">              6 :             pi_ = new sp_counted_impl_pd&lt;P, D&gt;(p, d);</span>
<span class="lineNum">     125 </span>                :         }
<span class="lineNum">     126 </span><span class="lineNoCov">              0 :         catch(...)</span>
<span class="lineNum">     127 </span>                :         {
<span class="lineNum">     128 </span><span class="lineNoCov">              0 :             d(p); // delete p</span>
<span class="lineNum">     129 </span><span class="lineNoCov">              0 :             throw;</span>
<span class="lineNum">     130 </span>                :         }
<span class="lineNum">     131 </span>                : 
<span class="lineNum">     132 </span>                : #else
<span class="lineNum">     133 </span>                : 
<span class="lineNum">     134 </span>                :         pi_ = new sp_counted_impl_pd&lt;P, D&gt;(p, d);
<span class="lineNum">     135 </span>                : 
<span class="lineNum">     136 </span>                :         if(pi_ == 0)
<span class="lineNum">     137 </span>                :         {
<span class="lineNum">     138 </span>                :             d(p); // delete p
<span class="lineNum">     139 </span>                :             boost::throw_exception(std::bad_alloc());
<span class="lineNum">     140 </span>                :         }
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                : #endif
<span class="lineNum">     143 </span><span class="lineCov">              6 :     }</span>
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span>                :     template&lt;class P, class D, class A&gt; shared_count( P p, D d, A a ): pi_( 0 )
<span class="lineNum">     146 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     147 </span>                :         , id_(shared_count_id)
<span class="lineNum">     148 </span>                : #endif
<span class="lineNum">     149 </span>                :     {
<span class="lineNum">     150 </span>                :         typedef sp_counted_impl_pda&lt;P, D, A&gt; impl_type;
<span class="lineNum">     151 </span>                :         typedef typename A::template rebind&lt; impl_type &gt;::other A2;
<span class="lineNum">     152 </span>                : 
<span class="lineNum">     153 </span>                :         A2 a2( a );
<span class="lineNum">     154 </span>                : 
<span class="lineNum">     155 </span>                : #ifndef BOOST_NO_EXCEPTIONS
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span>                :         try
<span class="lineNum">     158 </span>                :         {
<span class="lineNum">     159 </span>                :             pi_ = a2.allocate( 1, static_cast&lt; impl_type* &gt;( 0 ) );
<span class="lineNum">     160 </span>                :             new( static_cast&lt; void* &gt;( pi_ ) ) impl_type( p, d, a );
<span class="lineNum">     161 </span>                :         }
<span class="lineNum">     162 </span>                :         catch(...)
<span class="lineNum">     163 </span>                :         {
<span class="lineNum">     164 </span>                :             d( p );
<span class="lineNum">     165 </span>                : 
<span class="lineNum">     166 </span>                :             if( pi_ != 0 )
<span class="lineNum">     167 </span>                :             {
<span class="lineNum">     168 </span>                :                 a2.deallocate( static_cast&lt; impl_type* &gt;( pi_ ), 1 );
<span class="lineNum">     169 </span>                :             }
<span class="lineNum">     170 </span>                : 
<span class="lineNum">     171 </span>                :             throw;
<span class="lineNum">     172 </span>                :         }
<span class="lineNum">     173 </span>                : 
<span class="lineNum">     174 </span>                : #else
<span class="lineNum">     175 </span>                : 
<span class="lineNum">     176 </span>                :         pi_ = a2.allocate( 1, static_cast&lt; impl_type* &gt;( 0 ) );
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span>                :         if( pi_ != 0 )
<span class="lineNum">     179 </span>                :         {
<span class="lineNum">     180 </span>                :             new( static_cast&lt; void* &gt;( pi_ ) ) impl_type( p, d, a );
<span class="lineNum">     181 </span>                :         }
<span class="lineNum">     182 </span>                :         else
<span class="lineNum">     183 </span>                :         {
<span class="lineNum">     184 </span>                :             d( p );
<span class="lineNum">     185 </span>                :             boost::throw_exception( std::bad_alloc() );
<span class="lineNum">     186 </span>                :         }
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                : #endif
<span class="lineNum">     189 </span>                :     }
<span class="lineNum">     190 </span>                : 
<span class="lineNum">     191 </span>                : #ifndef BOOST_NO_AUTO_PTR
<span class="lineNum">     192 </span>                : 
<span class="lineNum">     193 </span>                :     // auto_ptr&lt;Y&gt; is special cased to provide the strong guarantee
<span class="lineNum">     194 </span>                : 
<span class="lineNum">     195 </span>                :     template&lt;class Y&gt;
<span class="lineNum">     196 </span>                :     explicit shared_count( std::auto_ptr&lt;Y&gt; &amp; r ): pi_( new sp_counted_impl_p&lt;Y&gt;( r.get() ) )
<span class="lineNum">     197 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     198 </span>                :         , id_(shared_count_id)
<span class="lineNum">     199 </span>                : #endif
<span class="lineNum">     200 </span>                :     {
<span class="lineNum">     201 </span>                : #ifdef BOOST_NO_EXCEPTIONS
<span class="lineNum">     202 </span>                : 
<span class="lineNum">     203 </span>                :         if( pi_ == 0 )
<span class="lineNum">     204 </span>                :         {
<span class="lineNum">     205 </span>                :             boost::throw_exception(std::bad_alloc());
<span class="lineNum">     206 </span>                :         }
<span class="lineNum">     207 </span>                : 
<span class="lineNum">     208 </span>                : #endif
<span class="lineNum">     209 </span>                : 
<span class="lineNum">     210 </span>                :         r.release();
<span class="lineNum">     211 </span>                :     }
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span>                : #endif 
<span class="lineNum">     214 </span>                : 
<span class="lineNum">     215 </span><span class="lineCov">            366 :     ~shared_count() // nothrow</span>
<span class="lineNum">     216 </span>                :     {
<span class="lineNum">     217 </span><span class="lineCov">            366 :         if( pi_ != 0 ) pi_-&gt;release();</span>
<span class="lineNum">     218 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     219 </span>                :         id_ = 0;
<span class="lineNum">     220 </span>                : #endif
<span class="lineNum">     221 </span><span class="lineCov">            366 :     }</span>
<span class="lineNum">     222 </span>                : 
<span class="lineNum">     223 </span><span class="lineCov">            251 :     shared_count(shared_count const &amp; r): pi_(r.pi_) // nothrow</span>
<span class="lineNum">     224 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     225 </span>                :         , id_(shared_count_id)
<span class="lineNum">     226 </span>                : #endif
<span class="lineNum">     227 </span>                :     {
<span class="lineNum">     228 </span><span class="lineCov">            251 :         if( pi_ != 0 ) pi_-&gt;add_ref_copy();</span>
<span class="lineNum">     229 </span><span class="lineCov">            251 :     }</span>
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                : #if defined( BOOST_HAS_RVALUE_REFS )
<span class="lineNum">     232 </span>                : 
<span class="lineNum">     233 </span>                :     shared_count(shared_count &amp;&amp; r): pi_(r.pi_) // nothrow
<span class="lineNum">     234 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     235 </span>                :         , id_(shared_count_id)
<span class="lineNum">     236 </span>                : #endif
<span class="lineNum">     237 </span>                :     {
<span class="lineNum">     238 </span>                :         r.pi_ = 0;
<span class="lineNum">     239 </span>                :     }
<span class="lineNum">     240 </span>                : 
<span class="lineNum">     241 </span>                : #endif
<span class="lineNum">     242 </span>                : 
<span class="lineNum">     243 </span>                :     explicit shared_count(weak_count const &amp; r); // throws bad_weak_ptr when r.use_count() == 0
<span class="lineNum">     244 </span>                :     shared_count( weak_count const &amp; r, sp_nothrow_tag ); // constructs an empty *this when r.use_count() == 0
<span class="lineNum">     245 </span>                : 
<span class="lineNum">     246 </span>                :     shared_count &amp; operator= (shared_count const &amp; r) // nothrow
<span class="lineNum">     247 </span>                :     {
<span class="lineNum">     248 </span>                :         sp_counted_base * tmp = r.pi_;
<span class="lineNum">     249 </span>                : 
<span class="lineNum">     250 </span>                :         if( tmp != pi_ )
<span class="lineNum">     251 </span>                :         {
<span class="lineNum">     252 </span>                :             if( tmp != 0 ) tmp-&gt;add_ref_copy();
<span class="lineNum">     253 </span>                :             if( pi_ != 0 ) pi_-&gt;release();
<span class="lineNum">     254 </span>                :             pi_ = tmp;
<span class="lineNum">     255 </span>                :         }
<span class="lineNum">     256 </span>                : 
<span class="lineNum">     257 </span>                :         return *this;
<span class="lineNum">     258 </span>                :     }
<span class="lineNum">     259 </span>                : 
<span class="lineNum">     260 </span><span class="lineCov">             27 :     void swap(shared_count &amp; r) // nothrow</span>
<span class="lineNum">     261 </span>                :     {
<span class="lineNum">     262 </span><span class="lineCov">             27 :         sp_counted_base * tmp = r.pi_;</span>
<span class="lineNum">     263 </span><span class="lineCov">             27 :         r.pi_ = pi_;</span>
<span class="lineNum">     264 </span><span class="lineCov">             27 :         pi_ = tmp;</span>
<span class="lineNum">     265 </span><span class="lineCov">             27 :     }</span>
<span class="lineNum">     266 </span>                : 
<span class="lineNum">     267 </span>                :     long use_count() const // nothrow
<span class="lineNum">     268 </span>                :     {
<span class="lineNum">     269 </span>                :         return pi_ != 0? pi_-&gt;use_count(): 0;
<span class="lineNum">     270 </span>                :     }
<span class="lineNum">     271 </span>                : 
<span class="lineNum">     272 </span>                :     bool unique() const // nothrow
<span class="lineNum">     273 </span>                :     {
<span class="lineNum">     274 </span>                :         return use_count() == 1;
<span class="lineNum">     275 </span>                :     }
<span class="lineNum">     276 </span>                : 
<span class="lineNum">     277 </span>                :     bool empty() const // nothrow
<span class="lineNum">     278 </span>                :     {
<span class="lineNum">     279 </span>                :         return pi_ == 0;
<span class="lineNum">     280 </span>                :     }
<span class="lineNum">     281 </span>                : 
<span class="lineNum">     282 </span>                :     friend inline bool operator==(shared_count const &amp; a, shared_count const &amp; b)
<span class="lineNum">     283 </span>                :     {
<span class="lineNum">     284 </span>                :         return a.pi_ == b.pi_;
<span class="lineNum">     285 </span>                :     }
<span class="lineNum">     286 </span>                : 
<span class="lineNum">     287 </span>                :     friend inline bool operator&lt;(shared_count const &amp; a, shared_count const &amp; b)
<span class="lineNum">     288 </span>                :     {
<span class="lineNum">     289 </span>                :         return std::less&lt;sp_counted_base *&gt;()( a.pi_, b.pi_ );
<span class="lineNum">     290 </span>                :     }
<span class="lineNum">     291 </span>                : 
<span class="lineNum">     292 </span>                :     void * get_deleter( sp_typeinfo const &amp; ti ) const
<span class="lineNum">     293 </span>                :     {
<span class="lineNum">     294 </span>                :         return pi_? pi_-&gt;get_deleter( ti ): 0;
<span class="lineNum">     295 </span>                :     }
<span class="lineNum">     296 </span>                : };
<span class="lineNum">     297 </span>                : 
<span class="lineNum">     298 </span>                : 
<span class="lineNum">     299 </span>                : class weak_count
<span class="lineNum">     300 </span>                : {
<span class="lineNum">     301 </span>                : private:
<span class="lineNum">     302 </span>                : 
<span class="lineNum">     303 </span>                :     sp_counted_base * pi_;
<span class="lineNum">     304 </span>                : 
<span class="lineNum">     305 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     306 </span>                :     int id_;
<span class="lineNum">     307 </span>                : #endif
<span class="lineNum">     308 </span>                : 
<span class="lineNum">     309 </span>                :     friend class shared_count;
<span class="lineNum">     310 </span>                : 
<span class="lineNum">     311 </span>                : public:
<span class="lineNum">     312 </span>                : 
<span class="lineNum">     313 </span>                :     weak_count(): pi_(0) // nothrow
<span class="lineNum">     314 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     315 </span>                :         , id_(weak_count_id)
<span class="lineNum">     316 </span>                : #endif
<span class="lineNum">     317 </span>                :     {
<span class="lineNum">     318 </span>                :     }
<span class="lineNum">     319 </span>                : 
<span class="lineNum">     320 </span>                :     weak_count(shared_count const &amp; r): pi_(r.pi_) // nothrow
<span class="lineNum">     321 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     322 </span>                :         , id_(weak_count_id)
<span class="lineNum">     323 </span>                : #endif
<span class="lineNum">     324 </span>                :     {
<span class="lineNum">     325 </span>                :         if(pi_ != 0) pi_-&gt;weak_add_ref();
<span class="lineNum">     326 </span>                :     }
<span class="lineNum">     327 </span>                : 
<span class="lineNum">     328 </span>                :     weak_count(weak_count const &amp; r): pi_(r.pi_) // nothrow
<span class="lineNum">     329 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     330 </span>                :         , id_(weak_count_id)
<span class="lineNum">     331 </span>                : #endif
<span class="lineNum">     332 </span>                :     {
<span class="lineNum">     333 </span>                :         if(pi_ != 0) pi_-&gt;weak_add_ref();
<span class="lineNum">     334 </span>                :     }
<span class="lineNum">     335 </span>                : 
<span class="lineNum">     336 </span>                :     ~weak_count() // nothrow
<span class="lineNum">     337 </span>                :     {
<span class="lineNum">     338 </span>                :         if(pi_ != 0) pi_-&gt;weak_release();
<span class="lineNum">     339 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     340 </span>                :         id_ = 0;
<span class="lineNum">     341 </span>                : #endif
<span class="lineNum">     342 </span>                :     }
<span class="lineNum">     343 </span>                : 
<span class="lineNum">     344 </span>                :     weak_count &amp; operator= (shared_count const &amp; r) // nothrow
<span class="lineNum">     345 </span>                :     {
<span class="lineNum">     346 </span>                :         sp_counted_base * tmp = r.pi_;
<span class="lineNum">     347 </span>                : 
<span class="lineNum">     348 </span>                :         if( tmp != pi_ )
<span class="lineNum">     349 </span>                :         {
<span class="lineNum">     350 </span>                :             if(tmp != 0) tmp-&gt;weak_add_ref();
<span class="lineNum">     351 </span>                :             if(pi_ != 0) pi_-&gt;weak_release();
<span class="lineNum">     352 </span>                :             pi_ = tmp;
<span class="lineNum">     353 </span>                :         }
<span class="lineNum">     354 </span>                : 
<span class="lineNum">     355 </span>                :         return *this;
<span class="lineNum">     356 </span>                :     }
<span class="lineNum">     357 </span>                : 
<span class="lineNum">     358 </span>                :     weak_count &amp; operator= (weak_count const &amp; r) // nothrow
<span class="lineNum">     359 </span>                :     {
<span class="lineNum">     360 </span>                :         sp_counted_base * tmp = r.pi_;
<span class="lineNum">     361 </span>                : 
<span class="lineNum">     362 </span>                :         if( tmp != pi_ )
<span class="lineNum">     363 </span>                :         {
<span class="lineNum">     364 </span>                :             if(tmp != 0) tmp-&gt;weak_add_ref();
<span class="lineNum">     365 </span>                :             if(pi_ != 0) pi_-&gt;weak_release();
<span class="lineNum">     366 </span>                :             pi_ = tmp;
<span class="lineNum">     367 </span>                :         }
<span class="lineNum">     368 </span>                : 
<span class="lineNum">     369 </span>                :         return *this;
<span class="lineNum">     370 </span>                :     }
<span class="lineNum">     371 </span>                : 
<span class="lineNum">     372 </span>                :     void swap(weak_count &amp; r) // nothrow
<span class="lineNum">     373 </span>                :     {
<span class="lineNum">     374 </span>                :         sp_counted_base * tmp = r.pi_;
<span class="lineNum">     375 </span>                :         r.pi_ = pi_;
<span class="lineNum">     376 </span>                :         pi_ = tmp;
<span class="lineNum">     377 </span>                :     }
<span class="lineNum">     378 </span>                : 
<span class="lineNum">     379 </span>                :     long use_count() const // nothrow
<span class="lineNum">     380 </span>                :     {
<span class="lineNum">     381 </span>                :         return pi_ != 0? pi_-&gt;use_count(): 0;
<span class="lineNum">     382 </span>                :     }
<span class="lineNum">     383 </span>                : 
<span class="lineNum">     384 </span>                :     bool empty() const // nothrow
<span class="lineNum">     385 </span>                :     {
<span class="lineNum">     386 </span>                :         return pi_ == 0;
<span class="lineNum">     387 </span>                :     }
<span class="lineNum">     388 </span>                : 
<span class="lineNum">     389 </span>                :     friend inline bool operator==(weak_count const &amp; a, weak_count const &amp; b)
<span class="lineNum">     390 </span>                :     {
<span class="lineNum">     391 </span>                :         return a.pi_ == b.pi_;
<span class="lineNum">     392 </span>                :     }
<span class="lineNum">     393 </span>                : 
<span class="lineNum">     394 </span>                :     friend inline bool operator&lt;(weak_count const &amp; a, weak_count const &amp; b)
<span class="lineNum">     395 </span>                :     {
<span class="lineNum">     396 </span>                :         return std::less&lt;sp_counted_base *&gt;()(a.pi_, b.pi_);
<span class="lineNum">     397 </span>                :     }
<span class="lineNum">     398 </span>                : };
<span class="lineNum">     399 </span>                : 
<span class="lineNum">     400 </span>                : inline shared_count::shared_count( weak_count const &amp; r ): pi_( r.pi_ )
<span class="lineNum">     401 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     402 </span>                :         , id_(shared_count_id)
<span class="lineNum">     403 </span>                : #endif
<span class="lineNum">     404 </span>                : {
<span class="lineNum">     405 </span>                :     if( pi_ == 0 || !pi_-&gt;add_ref_lock() )
<span class="lineNum">     406 </span>                :     {
<span class="lineNum">     407 </span>                :         boost::throw_exception( boost::bad_weak_ptr() );
<span class="lineNum">     408 </span>                :     }
<span class="lineNum">     409 </span>                : }
<span class="lineNum">     410 </span>                : 
<span class="lineNum">     411 </span>                : inline shared_count::shared_count( weak_count const &amp; r, sp_nothrow_tag ): pi_( r.pi_ )
<span class="lineNum">     412 </span>                : #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
<span class="lineNum">     413 </span>                :         , id_(shared_count_id)
<span class="lineNum">     414 </span>                : #endif
<span class="lineNum">     415 </span>                : {
<span class="lineNum">     416 </span>                :     if( pi_ != 0 &amp;&amp; !pi_-&gt;add_ref_lock() )
<span class="lineNum">     417 </span>                :     {
<span class="lineNum">     418 </span>                :         pi_ = 0;
<span class="lineNum">     419 </span>                :     }
<span class="lineNum">     420 </span>                : }
<span class="lineNum">     421 </span>                : 
<span class="lineNum">     422 </span>                : } // namespace detail
<span class="lineNum">     423 </span>                : 
<span class="lineNum">     424 </span>                : } // namespace boost
<span class="lineNum">     425 </span>                : 
<span class="lineNum">     426 </span>                : #ifdef __BORLANDC__
<span class="lineNum">     427 </span>                : # pragma warn .8027     // Functions containing try are not expanded inline
<span class="lineNum">     428 </span>                : #endif
<span class="lineNum">     429 </span>                : 
<span class="lineNum">     430 </span>                : #endif  // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
